<?php

class HmProjectController extends Fw_Controller_Action
{
	
	public function init()
	{
		$this->setDisplay('backoffice');
		$this->initSession();
	}

	public function editAction()
	{
		$model   = $this->_getModel('HmProject');
		$edit    = $this->_model;
		if($this->_request->isPost()) {
			$formData = $this->_request->getPost('edit');
			if($formData) {
				$project_id      = (int)$this->_request->getPost('project_id');
				$row             = $edit->fetchRow('project_id='.$project_id);
				$row->name       = $this->_request->getPost('name');
				$row->phone      = $this->_request->getPost('phone');
				$row->email      = $this->_request->getPost('email');
				$row->url        = $this->_request->getPost('url');
				$row->smtp_host  = $this->_request->getPost('smtp_host');
				$row->smtp_login = $this->_request->getPost('smtp_login');
				$row->smtp_pass  = $this->_request->getPost('smtp_pass');
				$row->smtp_port  = $this->_request->getPost('smtp_port');
				$row->smtp_auth  = $this->_request->getPost('smtp_auth');
				// $row->date_register = $this->edit('date_register');
				$row->save();
				
				return $this->_helper->redirector('index');
			}
		}
		$this->view->edit = $edit->fetchRow(
								$edit->select()
								->order('project_id DESC')
								->limit(1,0));
	}
}